package serive;

import Dao.AdminDao;
import Dao.AdminDaoImpl;
import entity.Mail;
import entity.User;

import java.util.List;

/**
 * @className: AdminImpl
 * @description: TODO 类描述
 * @author: Dong
 * @date: 2021/12/30
 **/
public class AdminServiceImpl implements AdminService {
    AdminDao adminDao = new AdminDaoImpl();

    @Override
    public boolean login(String id, String pwd) {
        String rPsw = adminDao.login(id);
        if (rPsw != null && rPsw.equals(pwd)) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public List<Mail> queryAllMail() {
        return adminDao.queryAllMail();
    }

    @Override
    public List<Mail> queryMail(String mid) {
        return adminDao.queryMail(mid);
    }

    @Override
    public List<User> queryUser() {
        return adminDao.queryAllUser();
    }

    @Override
    public User queryUser(String uid) {
        return adminDao.queryUser(uid);
    }

    @Override
    public boolean modify(String uId, String password1, String password2, String idCard, String sex, int age,
                          String address, String uName, String telephone) {
        if (password1.equals(password2)) {
            boolean isModify = adminDao.modifyUser(uId, password1, idCard, sex, age, address, uName, telephone);
            return isModify;
        } else return false;

    }

    @Override
    public boolean delete(String uid) {
       return adminDao.deleteUser(uid);
    }

    @Override
    public List<Mail> withoutDeliveryForThreeDays() {
        return adminDao.withoutDeliveryForThreeDays();
    }


}
